<?php
// Controller/Default.php

class Controller_Default extends FLEA_Controller_Action
{
    function actionindex(){
        $smarty =& $this->_getView();
        $smarty->display('index.html');
    }
    function actionclassfront(){
        $smarty =& $this->_getView();
        $name = empty($_GET['name'])?'grade1words':$_GET['name'];
        $page= (int)$_GET['page'];
        if(empty($page)){
            $page = 1; 
        }
        $table_sentences =& FLEA::getSingleton('Table_'.$name);
        FLEA::loadHelper('Pager');
        $pager =& new FLEA_Helper_Pager($table_sentences,$page,20,null,null,1);
        $data = $pager->findAll();
        $data_page = $pager->getPagerData();
        unset($data_page['pagesNumber']);
        $smarty->assign('data', $data);
        $smarty->assign('name', $name);
        $smarty->assign('data_page', $data_page);
        $smarty->display('classlistfront.html');
    }
    function actionimage(){
        $table_words = & FLEA::getSingleton('Table_tofowordpic');
        $smarty =& $this->_getView();
        $words = $table_words->find(3);
        $image =  imagecreatefromstring($words[PicBuf]);
        Header("Content-type:image/png"); 
        imagepng($image);
    }
    function actionimagebysize(){
        $table_words = & FLEA::getSingleton('Table_tofowordpic');
        $smarty =& $this->_getView();
        $words = $table_words->find(12);
        $image = imagecreatefromstring($words[PicBuf]);
        FLEA::loadFile('APP_Helper_MyImage');
        $out = new resizeimage($image,500,60,0);
        $image = $out->resize();
        Header("Content-type:image/png"); 
        imagepng($image);
    }
   function actiontest(){
	    $smarty =& $this->_getView();
        $table_words = & FLEA::getSingleton('Table_tofowordvoice');
        $words = $table_words->find(3);
    	$smarty->assign('voice', $words[id]);
	    $smarty->display('test.htm');  
    }
    function actionaudio(){
        // $table_words = & FLEA::getSingleton('Table_tofowordvoice');
        // $words = $table_words->find(1);
        // $test = file_get_contents('/home/fnsoxt/coding/result.mp3');
        $test = file_get_contents('templates/images/xinjing.mp3');
        Header("Content-type:audio/mp3"); 
        // print $words[VoiceData];
        print $test;
    }
}
